﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Tasks;

namespace FruitWeigher
{
	public partial class UIStartInterface : UserControl
	{
		public UIStartInterface()
		{
			// 为初始化变量所必需
			InitializeComponent();
            Btn_PlayAgin.Click += new RoutedEventHandler(Btn_PlayAgin_Click);
            ANI_Start.Completed += new EventHandler(ANI_Start_Completed);
            ItemInfo item1,item2;
            item1.Heft = 0;
            item1.Type = GSystem.GamesRandom.Next() % 5 + 1;
            item2.Heft = 0;
            item2.Type = GSystem.GamesRandom.Next() % 5 + 1;
            WeigherShow.CreateItemShow(item1, null, item2, null);
            Btn_Highest.Click += new RoutedEventHandler(Btn_Highest_Click);
            if (GamePlayCount.IsTrialMode)
            {
                Btn_BuyFull.Visibility = System.Windows.Visibility.Visible;
                Btn_BuyFull.Click += new RoutedEventHandler(Btn_BuyFull_Click);
            }
            else
                Btn_BuyFull.Visibility = System.Windows.Visibility.Collapsed;
		}

        void Btn_BuyFull_Click(object sender, RoutedEventArgs e)
        {
            
            if (MessageBox.Show(
                        "No remaining times,Buy fullversion or re-install,Are you buy now ?",
                        "No remaining times",
                        MessageBoxButton.OKCancel
                        ) == MessageBoxResult.OK)
            {
                MarketplaceDetailTask place = new MarketplaceDetailTask();
                //place.ContentType = MarketplaceContentType.Applications;
                //place.ContentIdentifier = GSystem.GUID;
                place.Show();
            }/*
            MarketplaceDetailTask place = new MarketplaceDetailTask();
            //place.ContentType = MarketplaceContentType.Applications;
            place.ContentIdentifier = GSystem.GUID;
            place.Show();*/
        }

        void Btn_Highest_Click(object sender, RoutedEventArgs e)
        {
            GSystem.IsStartShow = false;
            GSystem.HighestScore.Show();
        }

        void Btn_PlayAgin_Click(object sender, RoutedEventArgs e)
        {
            GSystem.IsStartShow = false;
            if (GamePlayCount.IsTrialMode)
            {
                if (GamePlayCount.Remainder <= 0)
                {
                    if (MessageBox.Show(
                        "No residual times,Buy fullversion or reinstall,Are you buy now ?",
                        "No residual times",
                        MessageBoxButton.OKCancel
                        ) == MessageBoxResult.OK)
                    {
                        MarketplaceDetailTask place = new MarketplaceDetailTask();
                        //place.ContentType = MarketplaceContentType.Applications;
                        //place.ContentIdentifier = GSystem.GUID;
                        place.Show();
                    }
                }
                else
                    ANI_Start.Begin();
            }
            else
            {
                ANI_Start.Begin();
            }
        }

        void ANI_Start_Completed(object sender, EventArgs e)
        {
            GSystem.Root.StartNewGame();
            this.Visibility = Visibility.Collapsed;
        }

	}
}